//  this library.
import 'package:hktk_app/ienum/subject/collection_type_enum.dart';
import 'package:hktk_app/model/practice/practice_question_model.dart';

/// 笔记模型
class NoteModel {
  String? createdTime;
  String? modifyTime;
  String? createdBy;
  String? modifyBy;
  String? id;

  /// 0.不公开， 1公开
  bool? open;

  /// 类型
  CollectionTypeEnum? type;

  /// 关联id
  String? relationId;

  /// 关联名
  String? relationName;

  /// 内容
  String? content;

  /// 是否审核， 0.未审 1.审核通过 2审核不通过 3自动通过
  int? verify;

  /// 试题id
  String? questionId;

  /// 科目id
  String? categoryId;

  /// 题干
  List<Stem>? stem;

  /// 发布者名
  String? createName;

  /// 发布者头像
  String? createHeader;

  NoteModel({
    this.createdTime,
    this.modifyTime,
    this.createdBy,
    this.modifyBy,
    this.id,
    this.open,
    this.type,
    this.relationId,
    this.relationName,
    this.content,
    this.verify,
    this.questionId,
    this.categoryId,
    this.stem,
    this.createName,
    this.createHeader,
  });

  NoteModel.fromJson(Map<String, dynamic> json) {
    createdTime = json['createdTime'];
    modifyTime = json['modifyTime'];
    createdBy = json['createdBy'];
    modifyBy = json['modifyBy'];
    id = json['id'];
    open = json['open'];
    if (json["type"] != null) {
      type = CollectionTypeEnum.getTypeEnum(json['type']);
    }
    relationId = json['relationId'];
    relationName = json['relationName'];
    content = json['content'];
    verify = json['verify'];
    questionId = json['questionId'];
    categoryId = json['categoryId'];
    if (json['stem'] != null) {
      stem = <Stem>[];
      json['stem'].forEach((v) {
        stem!.add(Stem.fromJson(v));
      });
    }
    createName = json['createName'];
    createHeader = json['createHeader'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['createdTime'] = createdTime;
    data['modifyTime'] = modifyTime;
    data['createdBy'] = createdBy;
    data['modifyBy'] = modifyBy;
    data['id'] = id;
    data['open'] = open;
    if (type != null) {
      data['type'] = type!.name;
    }
    data['relationId'] = relationId;
    data['relationName'] = relationName;
    data['content'] = content;
    data['verify'] = verify;
    data['questionId'] = questionId;
    data['categoryId'] = categoryId;
    if (stem != null) {
      data['stem'] = stem!.map((v) => v.toJson()).toList();
    }
    data['createName'] = createName;
    data['createHeader'] = createHeader;
    return data;
  }
}
